<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>網站管理系統</title>
	<link rel="icon" href="{!! asset('images/favicon.ico') !!}" type="image/x-icon">
	<link rel="stylesheet" href="/backstages/style/css/ch-ui.admin.css">
	<link rel="stylesheet" href="/backstages/style/font/css/font-awesome.min.css">
	<script type="text/javascript" src="/backstages/style/js/jquery-1.8.3.min.js" ></script>
</head>
<body style="background:#F3F3F4;">
	<div class="login_box">
		<h1>至尊寶</h1>
		<h2>網站管理系統</h2>
		<div class="form">
			<p style="color:red" class="msg"></p>
			<!-- <form action="login" method="post"> -->
				<ul>
					<li>
					<input type="text" autocomplete="off" name="username" class="text" placeholder="请输入用户名" />
						<span><i class="fa fa-user"></i></span>
					</li>
					<li>
						<!-- <input type="password"/> -->
						<input type="password"  autocomplete="new-password" name="password"  class="text" placeholder="请输入密码">
						<span><i class="fa fa-lock"></i></span>
					</li>
					<li>
						<input type="text" autocomplete="off" class="code" name="code" placeholder="请输入验证码" />
						<span><i class="fa fa-check-square-o"></i></span>
						<img src="{{ asset('backstage/code') }}" onclick="this.src='{{ asset('backstage/code') }}?'+Math.random()" alt="验证码" style="cursor: pointer;">
					</li>
					<li>
						<input type="submit" class="btn" onclick="login()" value="立即登錄"/>
					</li>
				</ul>
				
			<!-- </form> -->
			<p><a href="{!! url('/') !!}">返回首頁</a> &copy; 2017 Powered by <a href="{!! url('/') !!}" target="_blank">{!! url('/') !!}</a></p> 
		</div>
	</div>
<script type="text/javascript">

function login(){
	var name = $(":input[name='username']").val();
	var password = $(":input[name='password']").val();
	var code = $(":input[name='code']").val();
	$.post("userLogin",
	    {
	      name:name,
	      password:password,
	      code:code,
	      '_token':"{{ csrf_token() }}"
	    },
	    function(json){
	    	// console.log(json);
	    	if(json.res == 1){
	    		window.location.href = "/backstage/index";
	    	}else{
		    	$('.msg').html(json.msg);
	    	}
	    });
}

//回车提交事件

$("body").keyup(function (event) {
    if (event.which == 13){ 
        $(".btn").click();
    }  
});   

</script>
</body>
</html>


